package com.hzdl.house_mgr.controller;

import com.hzdl.house_mgr.bean.House;
import com.hzdl.house_mgr.bean.Img;
import com.hzdl.house_mgr.service.HouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Controller
@RequestMapping("viewHouse")
public class ViewHouseController {

    @Autowired
    private HouseService houseService;

    @RequestMapping("viewInit")
    public String viewHouse(Model model,Integer houseId){
        House house = houseService.findHouseByHid(houseId);
        model.addAttribute("house",house);
        List<Img> list = houseService.findImgById(houseId);
        House houseImg = houseService.findById(houseId);
        model.addAttribute("houseImg",houseImg);
        System.out.println(list);
        model.addAttribute("imgList",list);
        return "client/lookHouse";
    }
}
